package CGW.dao;

import CGW.bean.User;

import java.util.List;

public class UserDao extends BaseDao<User>{
    public List<User> all(int page, int pageSize){
        return all(User.class, page, pageSize);
    }

    public int total(){
        return count_rows(User.class);
    }

    public User get(int user_id){
        return get(User.class, "user_id", user_id);
    }

    public int add(User user){
        return add(user, "user_id");
    }

    public int update(User user){
        return update(user, "user_id");
    }

    public int delete(int user_id){
        return delete(User.class, "user_id", user_id);
    }

    public User login(String name, String pwd){
        List<User> list = query(User.class, "userName=? and passWord=?", name, pwd);
        if(list.isEmpty()) return null;
        return list.get(0);
    }
}
